package com.yuhanginfo.modules.web.entity;

import org.hibernate.validator.constraints.Length;
import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;

import javax.validation.constraints.NotNull;

import com.yuhanginfo.common.persistence.WebDataEntity;
import com.yuhanginfo.common.utils.Collections3;
import com.yuhanginfo.common.utils.StringUtils;
import com.yuhanginfo.common.utils.excel.annotation.ExcelField;

/**
 * 门店管理Entity
 * @author yangs
 * @version 2017-09-13
 */
public class WebYongUser extends WebDataEntity<WebYongUser> {
	
	public WebYongUser(String id, String loginName){
		super(id);
		this.loginName = loginName;
	}
	
	private static final long serialVersionUID = 1L;
	private String loginName;		// 登录名
	private String oldLoginName;// 原登录名
	private String email;		// 电子邮箱
	private String mobile;		// 手机号
	private String password;		// 密码
	private String name;		// 姓名
	private String beSysUserId;		// 所属业务员
	private String userType;		// 用户类型
	private String photo;		// 用户头像
	private String remark;		// 备注
	private String company;		// 公司名称
	private String dutyCode;		// 税号
	private String companySize;		// 公司规模
	private Date companyCreateTime;		// 企业认证时间
	private String companyType;		// 企业类型
	private String linkman;		// 联系人
	private String linkmanPhone;		// 联系人电话
	private String linkmanEmail;//联系人邮箱
	private String province;		// 省
	private String city;		// 市
	private String area;		// 区
	private String address;		// 详细地址
	private String blank;		// 开户银行
	private String blankCode;		// 银行账号
	private String examineState;		// 审核状态  0:审核通过 1:审核不通过
	private String taxRegistrationCertificate;		// 税务登记证
	private String organizationCodeCertificate;		// 组织机构代码证
	private String openBankAccountPermitCertificate;		// 银行开户许可证
	private String businessLicence;		// 营业执照
	private String titleImage;		// 门头照片
	private String loginFlag;		// 是否可登录:0否，1是
	private String beStoreCode;		// 所属门店号
	private String discount;		// 折扣系数
	private Date createDate;		// 创建时间
	private String xiaStore;
	private String salMan;
	private String suoStore;
	private String sysUserId;
	private Date startTime;
	private Date endTime;
	private Integer type;
	private List<WebStore> storeList = Lists.newArrayList(); // 所属门店列表
	private String provinceName;
	private String cityName;
	private String areaName;
	
	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public String getSysUserId() {
		return sysUserId;
	}

	public void setSysUserId(String sysUserId) {
		this.sysUserId = sysUserId;
	}

	public String getSuoStore() {
		return suoStore;
	}

	public void setSuoStore(String suoStore) {
		this.suoStore = suoStore;
	}

	public String getXiaStore() {
		return xiaStore;
	}

	public void setXiaStore(String xiaStore) {
		this.xiaStore = xiaStore;
	}

	public String getSalMan() {
		return salMan;
	}

	public void setSalMan(String salMan) {
		this.salMan = salMan;
	}

	public WebYongUser() {
		super();
	}

	public WebYongUser(String id){
		super(id);
	}

	@ExcelField(title="用户名", align=2, sort=10)  
	@Length(min=1, max=100, message="登录名长度必须介于 1 和 100 之间")
	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}
	
	@ExcelField(title="电子邮箱", align=2, sort=30)  
	@Length(min=1, max=50, message="电子邮箱长度必须介于 1 和 50 之间")
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
	
	@ExcelField(title="手机号", align=2, sort=20)  
	@Length(min=1, max=50, message="手机号长度必须介于 1 和 50 之间")
	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	
	@Length(min=1, max=50, message="密码长度必须介于 1 和 50 之间")
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	
	@Length(min=0, max=50, message="姓名长度必须介于 0 和 50 之间")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@Length(min=0, max=64, message="所属业务员长度必须介于 0 和 64 之间")
	public String getBeSysUserId() {
		return beSysUserId;
	}

	public void setBeSysUserId(String beSysUserId) {
		this.beSysUserId = beSysUserId;
	}
	
	@Length(min=0, max=1, message="用户类型长度必须介于 0 和 1 之间")
	public String getUserType() {
		return userType;
	}

	public void setUserType(String userType) {
		this.userType = userType;
	}
	
	@Length(min=0, max=50, message="用户头像长度必须介于 0 和 50 之间")
	public String getPhoto() {
		return photo;
	}

	public void setPhoto(String photo) {
		this.photo = photo;
	}
	
	@Length(min=0, max=255, message="备注长度必须介于 0 和 255 之间")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	@Length(min=0, max=50, message="公司名称长度必须介于 0 和 50 之间")
	public String getCompany() {
		return company;
	}

	public void setCompany(String company) {
		this.company = company;
	}
	
	@Length(min=0, max=11, message="税号长度必须介于 0 和 11 之间")
	public String getDutyCode() {
		return dutyCode;
	}

	public void setDutyCode(String dutyCode) {
		this.dutyCode = dutyCode;
	}
	
	@Length(min=0, max=11, message="公司规模长度必须介于 0 和 11 之间")
	public String getCompanySize() {
		return companySize;
	}

	public void setCompanySize(String companySize) {
		this.companySize = companySize;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@NotNull(message="企业认证时间不能为空")
	public Date getCompanyCreateTime() {
		return companyCreateTime;
	}

	public void setCompanyCreateTime(Date companyCreateTime) {
		this.companyCreateTime = companyCreateTime;
	}
	
	@Length(min=0, max=11, message="企业类型长度必须介于 0 和 11 之间")
	public String getCompanyType() {
		return companyType;
	}

	public void setCompanyType(String companyType) {
		this.companyType = companyType;
	}
	
	@Length(min=0, max=50, message="联系人长度必须介于 0 和 50 之间")
	public String getLinkman() {
		return linkman;
	}

	public void setLinkman(String linkman) {
		this.linkman = linkman;
	}
	
	@Length(min=0, max=50, message="联系人电话长度必须介于 0 和 50 之间")
	public String getLinkmanPhone() {
		return linkmanPhone;
	}

	public void setLinkmanPhone(String linkmanPhone) {
		this.linkmanPhone = linkmanPhone;
	}
	
	@Length(min=0, max=50, message="省长度必须介于 0 和 50 之间")
	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}
	
	@Length(min=0, max=50, message="市长度必须介于 0 和 50 之间")
	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}
	
	@Length(min=0, max=50, message="区长度必须介于 0 和 50 之间")
	public String getArea() {
		return area;
	}

	public void setArea(String area) {
		this.area = area;
	}
	
	@Length(min=0, max=50, message="详细地址长度必须介于 0 和 50 之间")
	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}
	
	@Length(min=0, max=50, message="开户银行长度必须介于 0 和 50 之间")
	public String getBlank() {
		return blank;
	}

	public void setBlank(String blank) {
		this.blank = blank;
	}
	
	@Length(min=0, max=50, message="银行账号长度必须介于 0 和 50 之间")
	public String getBlankCode() {
		return blankCode;
	}

	public void setBlankCode(String blankCode) {
		this.blankCode = blankCode;
	}
	
	@Length(min=0, max=11, message="审核状态长度必须介于 0 和 11 之间")
	public String getExamineState() {
		return examineState;
	}

	public void setExamineState(String examineState) {
		this.examineState = examineState;
	}
	
	@Length(min=0, max=255, message="税务登记证长度必须介于 0 和 255 之间")
	public String getTaxRegistrationCertificate() {
		return taxRegistrationCertificate;
	}

	public void setTaxRegistrationCertificate(String taxRegistrationCertificate) {
		this.taxRegistrationCertificate = taxRegistrationCertificate;
	}
	
	@Length(min=0, max=255, message="组织机构代码证长度必须介于 0 和 255 之间")
	public String getOrganizationCodeCertificate() {
		return organizationCodeCertificate;
	}

	public void setOrganizationCodeCertificate(String organizationCodeCertificate) {
		this.organizationCodeCertificate = organizationCodeCertificate;
	}
	
	@Length(min=0, max=255, message="银行开户许可证长度必须介于 0 和 255 之间")
	public String getOpenBankAccountPermitCertificate() {
		return openBankAccountPermitCertificate;
	}

	public void setOpenBankAccountPermitCertificate(String openBankAccountPermitCertificate) {
		this.openBankAccountPermitCertificate = openBankAccountPermitCertificate;
	}
	
	@Length(min=0, max=255, message="营业执照长度必须介于 0 和 255 之间")
	public String getBusinessLicence() {
		return businessLicence;
	}

	public void setBusinessLicence(String businessLicence) {
		this.businessLicence = businessLicence;
	}
	
	@Length(min=0, max=255, message="门头照片长度必须介于 0 和 255 之间")
	public String getTitleImage() {
		return titleImage;
	}

	public void setTitleImage(String titleImage) {
		this.titleImage = titleImage;
	}
	
	@Length(min=0, max=11, message="是否可登录:0否，1是长度必须介于 0 和 11 之间")
	public String getLoginFlag() {
		return loginFlag;
	}

	public void setLoginFlag(String loginFlag) {
		this.loginFlag = loginFlag;
	}
	
	@Length(min=1, max=30, message="所属门店号长度必须介于 1 和 30 之间")
	public String getBeStoreCode() {
		return beStoreCode;
	}

	public void setBeStoreCode(String beStoreCode) {
		this.beStoreCode = beStoreCode;
	}
	
	public String getDiscount() {
		return discount;
	}

	public void setDiscount(String discount) {
		this.discount = discount;
	}
	
	@ExcelField(title="注册时间", align=2, sort=40)  
	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public List<WebStore> getStoreList() {
		return storeList;
	}

	public void setStoreList(List<WebStore> storeList) {
		this.storeList = storeList;
	}

	public String getStoreName() {
		return Collections3.extractToString(storeList, "cnName", ",");
	}

	public String getProvinceName() {
		return provinceName;
	}

	public void setProvinceName(String provinceName) {
		this.provinceName = provinceName;
	}

	public String getCityName() {
		return cityName;
	}

	public void setCityName(String cityName) {
		this.cityName = cityName;
	}

	public String getAreaName() {
		return areaName;
	}

	public void setAreaName(String areaName) {
		this.areaName = areaName;
	}

	@JsonIgnore
	public List<String> getStoreIdList() {
		List<String> storeIdList = Lists.newArrayList();
		for (WebStore store : storeList) {
			String storeId=store.getId();
			if(storeId.indexOf('[')!=-1||storeId.indexOf(']')!=-1) {
				storeId=StringUtils.strip(storeId,"[]");
			}
			storeIdList.add(storeId);
		}
		return storeIdList;
	}
	
	@JsonIgnore
	public List<String> getStoreCodeList() {
		List<String> storeCodeList = Lists.newArrayList();
		for (WebStore store : storeList) {
			String storeCode=store.getCode();
			storeCodeList.add(storeCode);
		}
		return storeCodeList;
	}

	public void setStoreIdList(List<String> storeIdList) {
		for (String storeId : storeIdList) {
			WebStore store = new WebStore();
			store.setId(storeId);
			storeList.add(store);
		}
	}

	public String getOldLoginName() {
		return oldLoginName;
	}

	public void setOldLoginName(String oldLoginName) {
		this.oldLoginName = oldLoginName;
	}

	public String getLinkmanEmail() {
		return linkmanEmail;
	}

	public void setLinkmanEmail(String linkmanEmail) {
		this.linkmanEmail = linkmanEmail;
	}
}